package com.gome.ss.webserver.servlet.api;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gome.spiderkit.client.Utils;
import com.gome.ss.flowcrawl.extractor.FlowCrawlExtractorIndexDataListener;
import com.gome.ss.flowcrawl.plugin.FlowCrawlManager;

public class FlowCrawlExtractAddNotAnalyzedMappingField extends HttpServlet {
	
	/* /spiderkit/flowcrawl_extract_add_not_analyzed_mapping_field */
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		String fieldName = req.getParameter("fieldName");
		
		resp.setContentType("text/html;charset=gbk");
		req.setCharacterEncoding("gbk");
		
		try {
			FlowCrawlExtractorIndexDataListener.getInstance().appendNotAnalyzedMappingField(fieldName);
		} catch (Exception e) {
			String exception = Utils.getTrace(e);
			resp.getWriter().print(exception);
			resp.getWriter().close();
			return;
		}
		
		resp.getWriter().print("Success");
		resp.getWriter().close();
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doGet(req, resp);
	}

}
